#ifndef TABSANDTOOLBOXWIDGET_H
#define TABSANDTOOLBOXWIDGET_H

#include <QHBoxLayout>
#include <QTabWidget>
#include <QToolBox>
#include <QWidget>

#include <QInputDialog>
#include <QPushButton>

#include "ButtonsContainerWidget.h"
#include "DatabaseFillUpDialog.h"
#include "StockTableView.h"
#include "PrintDatabase.h"
#include "ItemEditDlg.h"
#include "dbms.h"

class TabsAndToolboxWidget : public QWidget
{
    Q_OBJECT
private:
    QTabWidget  *Tabs;
    QToolBox    *ToolBox;
    QHBoxLayout *MainLayout;
    QVBoxLayout *ToolBoxLayout;

    DBMS *dbms;
    StockTableView *Orders, *Income, *Stock, *Furniture, *Profile;
    DataBase *DB_Orders, *DB_Income, *DB_Stock, *DB_Materials, *DB_Furniture, *DB_Profile;

    OrderButtonsWidget *orderButtons;
    IncomeButtonsWidget *incomeButtons;
    StockButtonsWidget *stockButtons;

    ItemEditDlg *itemEditDialog;
    DatabaseFillUpDialog *fillUpDialog;

    PrintDatabase *PrintDB;

    int LastPressed;
    int LastOperation; // 1 - Order, 2 - Income
    int LastStatus;    // 1 - running, 2 - paused

    DataBase* LastDatabase;   // 0 - Orders, 1 - Income, 2 - Stock, 3 - Furniture, 4 - Profile
    StockTableView* LastTable;


private slots:
    void NewOrderPressed();
    void EditOrderPressed();
    void RemoveOrderPressed();
    void PauseOrderPressed();
    void ResumeOrderPressed();
    void PrintWantagePressed();


    void NewIncomePressed();
    void EditIncomePressed();
    void RemoveIncomePressed();
    void PauseIncomePressed();
    void ResumeIncomePressed();


    void AddOperation();
    void EditOperation();
    void RemoveOperation();
    void ResumePauseOperation();
    void AcceptOperation(QMap<QString,int> changes);


    void AddItemPressed();
    void EditItemPressed();
    int RemoveItemPressed();
    void PrintDatabasePressed();

    int AddItemToMaterials( const ItemType& item );
    int EditItemFromMaterials( const ItemType& item );

    void CheckForWantage( int i, int j );

    void GetItem( const ItemType& item );

    void TabChanged( int index );
    void ToolChanged( int index );

public:
    TabsAndToolboxWidget();
    ~TabsAndToolboxWidget();
};

#endif // TABSANDTOOLBOXWIDGET_H
